package gapidt;

import java.io.IOException;
import java.io.StringWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;

public class JaxbTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		class MySchemaOutputResolver extends SchemaOutputResolver {
			protected StringWriter stringWriter = new StringWriter();

		    public Result createOutput( String namespaceUri, String suggestedFileName ) throws IOException {
		    	Result result = new StreamResult(stringWriter);
		    	result.setSystemId("MySchemaOutputResolver");
		    	return result;
		    }
		    
		    public String getContent(){
		    	return stringWriter.toString();
		    }
		}

		try {
			JAXBContext context = JAXBContext.newInstance(java.lang.String.class);
			MySchemaOutputResolver outputResolver = new MySchemaOutputResolver();
			context.generateSchema(outputResolver);
			System.out.println(outputResolver.getContent());
		} catch (JAXBException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
